package com.sali.commons.disruptor;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

// 执行数据处理流程的线程工厂
public class ProcessThreadFactory implements ThreadFactory {

    private AtomicInteger idx = new AtomicInteger(0);

    // 任务名，标识当前线程处理的数据类型
    private String taskName;

    public ProcessThreadFactory(String taskName) {
        this.taskName = taskName;
    }

    @Override
    public Thread newThread(Runnable r) {
        return new Thread(r, taskName + "-" + idx.getAndIncrement());
    }
}
